<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登陆安全 - 安全数据查看</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/stv/admin/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/stv/admin/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid" style="max-width: 960px;">
    <div class="layui-row">
        <div class="layui-card">
            <div class="layui-card-header">
                <h1 style="text-align: center; color: red; font-size:large; font-weight: bold">安全无小事，请仔细确认登录记录是否正常</h1>
            </div>
            <div class="layui-card-body">
                <div class="layui-row">
                    <blockquote class="layui-elem-quote">最近登录信息(10条,<span
                            style="color: red;font-weight: bold">一经发现账号异常,请立即联系客服</span>
                        )
                    </blockquote>
                </div>
                <div class="layui-row">
                    <!-- 表格定义 -->
                    <table class="layui-table" id="main_table" lay-filter="main-table-filter"></table>
                </div>

            </div>
        </div>

        <!-- 按钮区 -->
        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">

                <div class="layui-footer" style="left: 0;">
                    <button id="form_yes" lay-filter="form_yes" class="layui-btn"
                            lay-submit="">
                        正常
                    </button>
                    <button id="form_no" type="button" class="layui-btn layui-btn-danger">异常</button>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 勿删，这里是显示帮助说明文，会调用系统菜单中的说明文档 -->
<div id="page_tip"></div>
<script src="/static/stv/admin/layuiadmin/layui/layui.js"></script>
<script src="/static/stv/admin/js/admin.common.js?{:time()}"></script>
<script>
    // ==========================  公共变量区  ===========================================
    var index_url = '{:url('login/log',['operate'=>$operate])}';
    //表格id
    var main_table_id = 'main_table';
    //搜索区的表单form id
    var search_form_id = 'search_form';
    //初始化后的表格对象
    var main_table;

    // ==========================  全局函数区  ===========================================

    //默认函数，重载当前页面数据，1、页面初始化 2、配合搜索 3、配合post_data等操作的回调，如：编辑或删除完表格的记录后，刷新当前页面等
    function reload_data(param) {
        //搜索表格
        do_search_table(main_table, search_form_id, param);
    }

    // ==============================  业务处理  ==============================================
    layui.use(['layer', 'laydate', 'table'], function () {

        //========================================== layui引用区 ==========================================
        var $ = layui.$,
            table = layui.table
            , form = layui.form
        ;
        var access_token=layui.data('user_table', {
            key: 'access_token'
        });
        console.log(access_token);
        // ==============================  业务区  =========================================
        //表格默认排序字段
        var table_sort = 'create_time';
        var table_order = 'desc';
        main_table = table.render({
            elem: '#' + main_table_id
            , url: index_url //异步数据接口
            , method: 'post' //接口http请求类型
           , headers: {'Authorization': 'Bearer '+access_token} //接口的请求头
            , initSort: { //初始化时的排序,如果不设的话，将无法标记表头的排序状态
                field: table_sort
                , type: table_order
            }
            , where: {sort: table_sort, order: table_order}
            , loading: true //显示加载
            , text: "无数据" //空数据时的异常提示
            , page: false //开启分页
            , cols: [[
                {title: '登陆时间', field: 'create_time', width: 160, sort: false, templet: layui_table_time_tpl_1}
                , {title: '登陆IP', field: 'action_ip', width: 160, sort: false}
                , {title: '登陆地区', field: 'ip_info', width: 200, sort: false}
                , {title: '登陆结果', field: 'remark', width: 380, sort: false}
            ]]
            , done: function (res, curr, count) {
                if (res.status == 403) {
                    layer.msg(res.message, {
                        offset: '15px'
                        , icon: 2
                        , time: 2000
                    }, function () {
                        //location.href = '{:url('login/index',['operate'=>$operate])}'; //跳到google验证码
                    });
                    return false;
                }
                //如果是异步请求数据方式，res即为你接口返回的信息。
                if (res.status != 200) {
                    show_error(res.message);
                }
                if (count == 0) {
                    layer.msg('暂无相关数据');
                }
            }
        });




        //其他按钮监听
        $("#form_yes").on('click', function () {
            location.href = '{:url('index/index',['operate'=>$operate])}';
        });


        //========================================== 渲染区 ==========================================
        //表单重新渲染，请保存到最后一行
        //渲染表单
        form.render(null, 'search_form');
    });
</script>
